package demo13;

/**
 * @program: qy158
 * @description:
 * @author: 闫克起2
 * @create: 2022-11-01 09:26
 **/
public class TestPriority {
    public static void main(String[] args) {
        PriorityDemo t1=new PriorityDemo("线程A");
        PriorityDemo t2=new PriorityDemo("线程B");
        PriorityDemo t3=new PriorityDemo("线程C");

        //优先级值越大 获取cpu的概率越高  执行完越早
        t1.setPriority(1);
        t2.setPriority(5);
        t3.setPriority(10);

        t1.start();
        t2.start();
        t3.start();

    }
}
class PriorityDemo extends Thread{
    PriorityDemo(String name){
        super(name);
    }
    @Override
    public void run() {
        for (int i = 0; i <20 ; i++) {
            System.out.println(Thread.currentThread().getName()+"~~~~~~~~~"+i);
        }
    }
}
